﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media.Effects;
using System.Windows.Media;
using System.Windows.Shapes;

namespace RS.ZhaoXiWidgets.Controls
{
    [TemplatePart(Name = nameof(PART_BtnDetail), Type = typeof(Button))]
    public class ZXCard2 : ContentControl
    {
        private Button PART_BtnDetail;
        static ZXCard2()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(ZXCard2), new FrameworkPropertyMetadata(typeof(ZXCard2)));
        }



        public string HeaderDes
        {
            get { return (string)GetValue(HeaderDesProperty); }
            set { SetValue(HeaderDesProperty, value); }
        }

        public static readonly DependencyProperty HeaderDesProperty =
            DependencyProperty.Register("HeaderDes", typeof(string), typeof(ZXCard2), new PropertyMetadata(string.Empty));



        public object HeaderContent
        {
            get { return (object)GetValue(HeaderContentProperty); }
            set { SetValue(HeaderContentProperty, value); }
        }

        public static readonly DependencyProperty HeaderContentProperty =
            DependencyProperty.Register("HeaderContent", typeof(object), typeof(ZXCard2), new PropertyMetadata(null));

       public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.PART_BtnDetail = (Button)this.GetTemplateChild(nameof(this.PART_BtnDetail));

            if (this.PART_BtnDetail!=null)
            {
                this.PART_BtnDetail.Click -= PART_BtnDetail_Click;
                this.PART_BtnDetail.Click += PART_BtnDetail_Click;
            }
        }

        public event Action BtnDetailClick;
        private void PART_BtnDetail_Click(object sender, RoutedEventArgs e)
        {
            BtnDetailClick?.Invoke();
        }
    }
}
